package com.juyu.miliao.api.dao.mysql;

import com.juyu.miliao.api.domain.dto.GameAllRankingListDTO;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Auther: 卜加超
 * @Date: 2019/8/20 14:41
 * @Description:
 */
@Repository
public class GameAllRankingListDao {
    @Resource
    private SqlSession sqlSession;


    public List<GameAllRankingListDTO> selectGameListByDay(LocalDate localDate) {
        return sqlSession.selectList("selectGameListByDay",localDate);
    }
    public GameAllRankingListDTO selectGameListByUserId(Long userId,LocalDate localDate) {
        Map<String, Object> params = new HashMap<>();
        params.put("userId", userId);
        params.put("localDate", localDate);
        return sqlSession.selectOne("selectGameListByUserId",params);
    }

    public List<GameAllRankingListDTO> selectGameListByWeek(LocalDate startTime, LocalDate endTime) {
        Map<String, Object> params = new HashMap<>();
        params.put("startTime", startTime);
        params.put("endTime", endTime);
        return sqlSession.selectList("selectGameListByWeek", params);
    }

    public List<GameAllRankingListDTO> selectGameListByUserIdAndTime(long userId, String startDate,
                                                                     String endDate) {
        Map<String,Object> parames = new HashMap<>(3);
        parames.put("userId",userId);
        parames.put("startDate",startDate);
        parames.put("endDate",endDate);
        return sqlSession.selectList("selectGameListByUserIdAndTime",parames);
    }
}
